# 主程序入口
import tkinter as tk
import atexit
import sys
from gui.main_window import MainWindow
from gui.theme_config import apply_theme
from db.database_manager import MySQLDatabaseManager as DatabaseManager

# 修改环境检查函数
def check_environment() -> bool:
    if sys.version_info < (3, 8):
        print("需要Python 3.8或更高版本")
        return False
    try:
        import pymysql  # 改为检查PyMySQL
        from dbutils import pooled_db
    except ImportError as e:
        print(f"缺少依赖包: {str(e)}\n请执行: pip install pymysql dbutils")
        return False
    return True


if __name__ == "__main__":
    if not check_environment():
        sys.exit(1)

    atexit.register(DatabaseManager.close_all_connections)
    root = tk.Tk()
    root.title("智能万年历")
    apply_theme(root)
    app = MainWindow(root)
    root.mainloop()
